import axios from 'axios'
import {getToken} from "./auth";

const service = axios.create({
    baseURL: import.meta.env.VITE_BASE_API,
    timeout: 10000
})

service.interceptors.request.use(config => {
    const isToken = (config.headers ?? {}).isToken === false
    const token = getToken()
    if (token && !isToken) {
        config.headers['Authorization'] = 'Bearer ' + token
    }
    return config
}, error => {
    console.log(error)
    Promise.reject(error)
})
export default service
